package com.redlight.base;

import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;

import java.util.Iterator;
import java.util.List;

/**
 * Created by chao on 2019/1/9.
 */
public class SysRoleBase extends BaseEntity  {
    private SysOrgBase office;
    private String name;
    private String enname;
    private String roleType;
    private String dataScope;
    private String isSys;
    private List<SysMenuBase> menuList = Lists.newArrayList();
    private List<SysOrgBase> officeList = Lists.newArrayList();
    public static final String DATA_SCOPE_ALL = "1";
    public static final String DATA_SCOPE_COMPANY_AND_CHILD = "2";
    public static final String DATA_SCOPE_COMPANY = "3";
    public static final String DATA_SCOPE_OFFICE_AND_CHILD = "4";
    public static final String DATA_SCOPE_OFFICE = "5";
    public static final String DATA_SCOPE_SELF = "8";
    public static final String DATA_SCOPE_CUSTOM = "9";

    public SysRoleBase() {
    }

    public SysRoleBase(String id) {
        super(id);
    }

    public SysOrgBase getOffice() {
        return this.office;
    }

    public void setOffice(SysOrgBase office) {
        this.office = office;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEnname() {
        return this.enname;
    }

    public void setEnname(String enname) {
        this.enname = enname;
    }

    public String getRoleType() {
        return this.roleType;
    }

    public void setRoleType(String roleType) {
        this.roleType = roleType;
    }

    public String getDataScope() {
        return this.dataScope;
    }

    public void setDataScope(String dataScope) {
        this.dataScope = dataScope;
    }

    public String getIsSys() {
        return this.isSys;
    }

    public void setIsSys(String isSys) {
        this.isSys = isSys;
    }

    public List<SysMenuBase> getMenuList() {
        return this.menuList;
    }

    public void setMenuList(List<SysMenuBase> menuList) {
        this.menuList = menuList;
    }

    public List<String> getMenuIdList() {
        List<String> menuIdList = Lists.newArrayList();
        Iterator var2 = this.menuList.iterator();

        while(var2.hasNext()) {
            SysMenuBase menu = (SysMenuBase)var2.next();
            menuIdList.add(menu.getId());
        }

        return menuIdList;
    }

    public void setMenuIdList(List<String> menuIdList) {
        this.menuList = Lists.newArrayList();
        Iterator var2 = menuIdList.iterator();

        while(var2.hasNext()) {
            String menuId = (String)var2.next();
            SysMenuBase menu = new SysMenuBase();
            menu.setId(menuId);
            this.menuList.add(menu);
        }

    }

    public String getMenuIds() {
        return StringUtils.join(this.getMenuIdList(), ",");
    }

    public void setMenuIds(String menuIds) {
        this.menuList = Lists.newArrayList();
        if(menuIds != null) {
            String[] ids = StringUtils.split(menuIds, ",");
            this.setMenuIdList(Lists.newArrayList(ids));
        }

    }

    public List<SysOrgBase> getOfficeList() {
        return this.officeList;
    }

    public void setOfficeList(List<SysOrgBase> officeList) {
        this.officeList = officeList;
    }

    public List<String> getOfficeIdList() {
        List<String> officeIdList = Lists.newArrayList();
        Iterator var2 = this.officeList.iterator();

        while(var2.hasNext()) {
            SysOrgBase office = (SysOrgBase)var2.next();
            officeIdList.add(office.getId());
        }

        return officeIdList;
    }

    public void setOfficeIdList(List<String> officeIdList) {
        this.officeList = Lists.newArrayList();
        Iterator var2 = officeIdList.iterator();

        while(var2.hasNext()) {
            String officeId = (String)var2.next();
            SysOrgBase office = new SysOrgBase();
            office.setId(officeId);
            this.officeList.add(office);
        }

    }

    public String getOfficeIds() {
        return StringUtils.join(this.getOfficeIdList(), ",");
    }

    public void setOfficeIds(String officeIds) {
        this.officeList = Lists.newArrayList();
        if(officeIds != null) {
            String[] ids = StringUtils.split(officeIds, ",");
            this.setOfficeIdList(Lists.newArrayList(ids));
        }

    }

    public List<String> getPermissions() {
        List<String> permissions = Lists.newArrayList();
        Iterator var2 = this.menuList.iterator();

        while(var2.hasNext()) {
            SysMenuBase menu = (SysMenuBase)var2.next();
            if(menu.getPermission() != null && !"".equals(menu.getPermission())) {
                permissions.add(menu.getPermission());
            }
        }

        return permissions;
    }
}
